package com.test

import com.google.gson.GsonBuilder
import kotlin.properties.Delegates

fun main() {
    val user = User()
    user.name = "hawking"
    println("--------------")
    val user2 = User2(mapOf(
            "name" to "john",
            "age" to 13,
            "sex" to "male"
    ))
    println(user2)
    val gson = GsonBuilder().setPrettyPrinting().create()
    println(gson.toJson(user))
}

data class User2(val map: Map<String, Any?>) {
    val name: String by map
    val age: Int by map
    val sex: String by map
}

class User {
    var name: String by Delegates.observable("initialValue") { _, old, new ->
        println("property = old = [${old}], new = [${new}]")

    }
}